#include<bits/stdc++.h>
using namespace std;
long long f[100011];
int a[100011];
vector<int> v[100011];
bool flag;
void DFS(int p,int fa)
{
	if(v[p].size() <= 1)
		return f[p] = a[p],void();
	long long s = 0,mx = 0;
	for(auto i:v[p]) if(i != fa)
	{
		DFS(i,p);
		s += f[i],mx = max(mx,f[i]);
	}
	f[p] = 2ll * a[p] - s;
	if(f[p] < 0)
		return flag = 0,void();
	long long rst = s - mx,x = (s - f[p]) / 2;
	if(rst < x)
		return flag = 0,void();
}
int n,rt;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("clean.in","r",stdin);
	freopen("clean.out","w",stdout);
	int T;
	cin >> T;
	while(T--)
	{
		cin >> n;
		for(int i = 1;i <= n;i++) v[i].clear();
		for(int i = 1;i <= n;i++) cin >> a[i];
		for(int i = 1;i < n;i++)
		{
			int x,y;
			cin >> x >> y;
			v[x].push_back(y),v[y].push_back(x);
		}
		if(n == 1)
		{
			cout << (a[1] ? "NO\n" : "YES\n");
			continue;
		}else if(n == 2)
		{
			cout << (a[1] == a[2] ? "YES\n" : "NO\n");
			continue;
		}
		for(int i = 1;i <= n;i++) if(v[i].size() != 1)
			rt = i;
		flag = 1;
		DFS(rt,0);
		cout << ((f[rt] || !flag) ? "NO\n" : "YES\n");
	}
	return 0;
}
//mind:n = 1,n = 2